package views;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.swing.CellEditor;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

import calendar_ex.Appointment;
import calendar_ex.CalendarDate;
import calendar_ex.CalendarEx;
import calendar_ex.CalendarTime;

public class MonthView extends JPanel{
	
		public MonthView(){ 


		String[] headers = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; //All headers
		Object[][] rowData = new Object[6][7];
		
		CalendarDate tempDay = new CalendarDate(10,10,2009);
		//that day indicates the current month
		//how many days does the current month have
		int noDays = tempDay.getNoDays(tempDay.month);
		System.out.printf("no of days in month %s \n", noDays);
		//which day of the week is is the first day of the month
		int dayOfWeek = tempDay.getDayInt(tempDay.day, tempDay.month, tempDay.year);
		System.out.printf("the first day of the weeek %s \n", dayOfWeek);
		//process the Date to represent a CalendarDate
		int rowNo = 0;
		for(int i = 1; i < noDays+1; i++){
			rowData[rowNo][dayOfWeek] = i;
			dayOfWeek++;
			if(dayOfWeek%7 == 0){
				rowNo++;
				dayOfWeek = 0;}
			
		}
		
		CalendarEx calData = new CalendarEx();
        calData.openCalendar("calendar.txt");
        Calendar calendar = Calendar.getInstance();
		Date today = calendar.getTime();
		int dateDay = today.getDate();
		int dateMonth = today.getMonth();
		int dateYear = today.getYear();
		int hour = calendar.HOUR;
		
		CalendarDate start = new CalendarDate(26,9,2009);
		CalendarDate end = new CalendarDate(6,11, 2009);
		//range of month is 0 - 11
		//what is the current day
		

		DefaultTableModel dataModel = new DefaultTableModel(rowData, headers);

		JTable table = new JTable(dataModel);
		table.setRowHeight(100);
		
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		JScrollPane wvPanel = new JScrollPane(table);
		wvPanel.setPreferredSize(new Dimension(355,500));
		add(wvPanel);
	}

}
